package com.cxj.link.util;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import com.cxj.link.R;
import com.cxj.link.view.CutImage;

public class ImageUtil {
    private static List<Integer> imageValues = getImageValues();

    public static List<Integer> getImageValues() {
        ArrayList localArrayList;
        Field[] arrayOfField = R.drawable.class.getFields();
        localArrayList = new ArrayList();
        int i = arrayOfField.length;
        int j = 0;
        while (j < i) {
            try {
                Field localField = arrayOfField[j];
                if (localField.getName().indexOf("p_") == -1)
                    continue;
                localArrayList.add(Integer.valueOf(localField.getInt(R.drawable.class)));
                j++;
            } catch (Exception localException) {
                localArrayList = null;
                break;
            }
        }
        return localArrayList;
    }

    public static List<CutImage> getPlayImages(Context paramContext, int paramInt) {
        Object localObject = getPlayValues(paramInt);
        ArrayList localArrayList = new ArrayList();
        localObject = ((List) localObject).iterator();
        while (((Iterator) localObject).hasNext()) {
            Integer localInteger = (Integer) ((Iterator) localObject).next();
            localArrayList.add(new CutImage(BitmapFactory.decodeResource(paramContext.getResources(),
                    localInteger.intValue()), localInteger.intValue()));
        }
        return localArrayList;
    }

    public static List<Integer> getPlayValues(int paramInt) {
        if (paramInt % 2 != 0)
            paramInt++;
        List localList = getRandomValues(imageValues, paramInt / 2);
        localList.addAll(localList);
        Collections.shuffle(localList);
        return localList;
    }

    public static List<Integer> getRandomValues(List<Integer> paramList, int paramInt) {
        Random localRandom = new Random();
        ArrayList localArrayList = new ArrayList();
        int i = 0;
        while (i < paramInt) {
            try {
                localArrayList.add(paramList.get(localRandom.nextInt(paramList.size())));
                i++;
            } catch (IndexOutOfBoundsException localIndexOutOfBoundsException) {
            }
        }
        return localArrayList;
    }

    public static Bitmap getSelectImage(Context paramContext) {
        return BitmapFactory.decodeResource(paramContext.getResources(), 2130837546);
    }

    public static Bitmap getSelectImage2(Context paramContext) {
        return BitmapFactory.decodeResource(paramContext.getResources(), 2130837547);
    }
}
